
#region Imports

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;

#endregion

namespace Justa.Data.Provider
{
    /// <summary>
    /// 
    /// </summary>
    /// 
    public class DataAccessProviderFactory
    {
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="name"></param>
        /// 
        /// <returns></returns>
        /// 
        public static DataAccessProvider CreateDatabase(string name)
        {
            DataAccessProvider provider = DataAccessProviderManager.Instance.DefaultProvider;
            provider.DatabaseInstance = name;
            provider.Init();

            return provider;
        }

        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="name"></param>
        /// <param name="providerName"></param>
        /// 
        /// <returns></returns>
        /// 
        public static DataAccessProvider CreateDatabase(string name, string providerName)
        {
            DataAccessProvider provider = DataAccessProviderManager.Instance.GetProvider(providerName);

            if (provider == null)
            {
                throw new ArgumentException("Specified provider name does not exist.");
            }
            provider.DatabaseInstance = name;
            provider.Init();

            return provider;
        }
    }
}
